import { createSlice } from '@reduxjs/toolkit'

export default createSlice({
  // 命名空间-模块名
  name: 'user',

  //初始状态
  initialState: {
    username: '张三',
    token: 'xxx',
  },

  //修改状态的方法
  reducers: {
    updateUsername(state, action) {
      state.username = action.payload
    },

    updateToken(state, action) {
      state.token = action.payload
    },
  },
})
